class AccountPrase{
    public constructor() {
	}
    private static _instance:AccountPrase;

    public static instance():AccountPrase{
		if(!AccountPrase._instance){
			AccountPrase._instance = new AccountPrase();
		}
		return AccountPrase._instance;
	}

	public account(parma)
	{
		let data = {
            version:GameConst.version,
			level:parma.customs,
			fruit_list:parma.fruit_list,
        	one_cut_num:parma.one_cut_num,
			current_weapon:RoleCache.instance().curWeaponId
        }
		HttpManager.instance().sendPost(GameConst.httpUrl + 'warrioruser/balance', StringUtil.jsonToHttpPostString(data), (e)=>{
            let data = JSON.parse(e)
            if(data && data.data)
			{
				let curCustoms = GameManager.instance.curCustoms;
				if(data.data.get_weapon && data.data.get_weapon.id != 0)
				{
					// GameManager.instance.isCanShowLuckyWeapon = data.data.get_weapon;
					let luckData = data.data.get_weapon;
					GameManager.instance.isCanShowLuckyWeapon = luckData.id;
					GameManager.instance.isGetLuckyWeaponByShare = (luckData.path == 'share');
				}
            	RankManager.instance().uploadUserScore(curCustoms,'score');
				let coin = data.data.coin;
				let diamond = data.data.diamond;
				let percent = data.data.percent;//武器收益加成
				let multiple = data.data.multiple;//随机视频翻倍
				let da = {
					isPop:true,
					// type:alertType.nextCustoms,
					percent:percent,
					multiple:multiple,
					gold:coin,
					diamond:diamond
				}
				UIManager.instance().openUILogic(AccountUI, da);
			}
        }, this);
	}

	public task_account(parma)
	{
		let data = {
            version:GameConst.version,
			level:parma.customs
        }
		HttpManager.instance().sendPost(GameConst.httpUrl + 'warrioruser/task_balance', StringUtil.jsonToHttpPostString(data), (e)=>{
            let data = JSON.parse(e)
            if(data && data.data)
			{
				let curCustoms = GameManager.instance.curCustoms;
            	RankManager.instance().uploadUserScore(curCustoms,'score');
				GameManager.instance.curCustoms++;//任务关卡计入普通关卡中
				let coin = data.data.coin;
				let diamond = data.data.diamond;
				let da = {
					isPop:true,
					type:alertType.task,
					gold:coin,
					diamond:diamond
				}
				UIManager.instance().openUILogic(AlertUI, da);
			}
        }, this);
	}

	public special_account(parma)
	{
		let data = {
            version:GameConst.version,
			fruit_num:parma.fruit_num
        }
		HttpManager.instance().sendPost(GameConst.httpUrl + 'warrioruser/special_balance', StringUtil.jsonToHttpPostString(data), (e)=>{
            let data = JSON.parse(e)
            if(data && data.data)
			{
				let coin = data.data.coin;
				let diamond = data.data.diamond;
				let da = {
					isPop:true,
					type:alertType.special,
					gold:coin,
					diamond:diamond
				}
				UIManager.instance().openUILogic(AlertUI, da);
			}
        }, this);
	}

	public mul_account(parma)
	{
		let da = {
            version:GameConst.version,
			multiple:parma.multiple,
			coin:parma.coin,
			diamond:parma.diamond
        }
		HttpManager.instance().sendPost(GameConst.httpUrl + 'warrioruser/multiple_balance', StringUtil.jsonToHttpPostString(da), (e)=>{
            let data = JSON.parse(e)
            if(data && data.data)
			{
				let coin = data.data.coin;
				let diamond = data.data.diamond;
				let da = {
					isPop:true,
					type:alertType.nextCustoms,
					gold:coin,
					diamond:diamond
				}
				UIManager.instance().openUILogic(AlertUI, da);
			}
        }, this);
	}
}